<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<?php
    /*$data = unserialize($row['product_discount']);
    if($data){
      $keys = array_keys($data);
    }else{
        $keys=array();
    }*/
    $data = [];
    $keys = [];

?>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_name" data-rule="required" class="form-control form-control" name="row[agent_name]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_phone')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_phone" data-rule="required" class="form-control form-control" name="row[agent_phone]" type="text">
        </div>
    </div>    
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">密码:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-password" data-rule="required" class="form-control " value="123456" name="row[password]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Branch_office')}:</label>
        <div class="col-xs-12 col-sm-8">
             {:build_radios('row[branch_office]', ['1'=>__('Branch_office 1'), '2'=>__('Branch_office 2')],2)}
        </div>
    </div> 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Addre')}:</label>
        <div class="col-xs-12 col-sm-8">
          {:Form::cxselect('ajax/area', ['province','city','area'], ['province'=>'', 'city'=>'','area'=>''])}
        </div>
    </div>
    
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_region')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_region" class="form-control form-control" name="row[agent_region]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Term_start')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-term_start" class="form-control datetimepicker form-control" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[term_start]" data-rule="{:__('Term_start')}:required" type="text" value="{:date('Y-m-d')}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Term_end')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-term_end" class="form-control datetimepicker form-control" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[term_end]" type="text" data-rule="{:__('Term_end')}:required" value="{:date('Y-m-d')}">
        </div>
    </div>
     <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Send_country')}:</label>
        <div class="col-xs-12 col-sm-8">
             {:build_radios('row[send_country]', ['1'=>__('Send_country 1'), '2'=>__('Send_country 2')])}
        </div>
    </div> 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-address"  class="form-control form-control" name="row[address]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_code')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_code" class="form-control form-control" name="row[agent_code]" type="number">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_contact')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_contact" class="form-control form-control" name="row[agent_contact]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_tel')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_tel" class="form-control form-control" name="row[agent_tel]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_fax')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_fax" class="form-control form-control" name="row[agent_fax]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Clerk')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-clerk"   data-source="/api/base/user" data-primary-key="userid" data-field="username"  data-params='{"custom[id]":"1"}'  class="form-control selectpage" name="row[clerk]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Docking')}:</label>
        <div class="col-xs-12 col-sm-8">
          <input id="c-docking"   data-source="/api/base/user" data-primary-key="userid" data-field="username"  data-params='{"custom[id]":"1"}'  class="form-control selectpage" name="row[docking]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Bond_amount')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-bond_amount" data-rule="required" class="form-control form-control" step="0.01" name="row[bond_amount]" type="number" value="0.00">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Deduction_amount')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-deduction_amount" data-rule="required" class="form-control form-control" step="0.01" name="row[deduction_amount]" type="number" value="0.00">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Finance_invoice')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-finance_invoice" class="form-control form-control" name="row[finance_invoice]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Finance_taxnumber')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-finance_taxnumber" class="form-control form-control" name="row[finance_taxnumber]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Account_name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-account_name" class="form-control form-control" name="row[account_name]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Account_bank')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-account_bank" class="form-control form-control" name="row[account_bank]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Bank_number')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-bank_number" class="form-control form-control" name="row[bank_number]" type="text">
        </div>
    </div>
    <div class="form-group row">
        <label class="control-label col-xs-12 col-sm-2">{:__('产品折扣')}:</label>
        <div class="col-xs-12 col-sm-8">
            <dl class="fieldlist" data-template="eventtpl" data-name="row[discount_array]">
                <dd><ins>{:__('产品')}</ins><ins>{:__('单位')}</ins><ins>{:__('折扣(10-100)')}</ins></dd>
                <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append" id="add-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
                <!--请注意 dd和textarea间不能存在其它任何元素，实际开发中textarea应该添加个hidden进行隐藏-->
                <textarea name="row[discount_array]" class="form-control " cols="30" rows="5"></textarea>
            </dl>
            <script id="eventtpl" type="text/html">
                <dd class="form-inline">
                    <ins>
                        <input type="text" name="<%=name%>[<%=index%>][id]" class="form-control selectpage" data-source="ajax/product"  data-field="name" value="<%=row.id%>" placeholder="产品" />
                    </ins>
                    <ins>
                        <input type="text" name="<%=name%>[<%=index%>][dw]" class="form-control selectpage" data-source="ajax/dw"   data-field="name"  value="<%=row.dw%>" placeholder="单位"/>
                    </ins>
                    <ins>
                        <input type="text" name="<%=name%>[<%=index%>][discount]" class="form-control" value="<%=row.discount%>" placeholder="折扣"/>
                    </ins>
                    <!--下面的两个按钮务必保留-->
                    <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span>
                    <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
                </dd>
            </script>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('往来单位编码')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-finance_code" class="form-control form-control" name="row[finance_code]" type="text">
        </div>
    </div>
    <div class=" panel panel-default" style="text-align: center;height: 500px;width: 66%;margin-left: 17%;">
        <div class="panel-heading" style="height: 7%">
            <h3 class="panel-title">代理商产品折扣</h3>
        </div>
         <div class="fixed-table-body panel-body" style="height: 93%">
         <dl class="fieldlist" id="fieldlist" data-index="1">
              <dd id="bappend">
                  <a href="javascript:;" class="btn btn-sm btn-success" id="append"><i class="fa fa-plus"></i>
                    {:__('Append')}
                  </a>
              </dd>
              <dd>
                  <ins>分类</ins>
                  <ins>折扣(1-10)</ins>
              </dd>
                {foreach name="cate_info" item="va" key="k" }
                  <dd class="form-inline hidden">
                    <select  id="selet_{$k}"   class="form-control selet"  name="product_discount[{$k}][id]">
                        <option selected value="0">请选择</option>
                        {foreach name="cate_info" item="vo" key="key"}
                        <option  value="{$vo['id']}">{$vo['name']}</option>
                        {/foreach}
                    </select>
                    <input id="c-product_discount{$va['id']}" data-rule="range(1~10)" min="1" max="10" class="form-control form-control" name="product_discount[{$k}][discount]" type="number" value="10" size="10">
                    <span class="btn btn-sm btn-danger btn-removes"><i class="fa fa-times"></i></span>
                  </dd>
               {/foreach}
         </dl>
        </div>
    </div>
    <div class="form-group row">
        <label class="control-label col-xs-12 col-sm-2">{:__('Excel模板导入')}:</label>
        <div class="col-xs-12 col-sm-8">
            <dl class="fieldlist" data-template="eventtpl2"  data-name="row[excle_array]">
                <dd><ins>{:__('数据字段')}</ins><ins>{:__('Excle标题')}</ins></ins></dd>
                <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append" id="excel-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
                <!--请注意 dd和textarea间不能存在其它任何元素，实际开发中textarea应该添加个hidden进行隐藏-->
                <textarea name="row[excle_array]" class="form-control hidden" cols="30" rows="5">[{"key":"order_sn","value":""},{"key":"goods_name","value":""},{"key":"xdtime","value":""},{"key":"gifts","value":""},{"key":"amount","value":""},{"key":"receipt","value":""},{"key":"phone","value":""},{"key":"address","value":""},{"key":"import_note","value":""}]</textarea>
            </dl>
            <script id="eventtpl2" type="text/html">
                <dd class="form-inline">
                    <ins>
                        <input type="text" name="<%=name%>[<%=index%>][key]" class="form-control"  value="<%=row.key%>"/>
                    </ins>
                    <ins>
                        <input type="text" name="<%=name%>[<%=index%>][value]" class="form-control" value="<%=row.value%>"/>
                    </ins>
                </dd>
            </script>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
